using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using octalforty.Componento.Web.Shared.Data;

namespace octalforty.Componento.Web.Controllers
{
    public class BrowseController : Controller
    {
        //
        // GET: /Browse/

        public ActionResult Index()
        {
            using(var dataContext = new ComponentoDataContext())
            {
                var components = from c in dataContext.Components
                                 orderby c.Name
                                 select c;

                return View(components.Select(
                    x => new Models.ComponentModel
                        {
                            Name = x.Name, 
                            Description = x.Description,
                            Version = x.Version,
                            ProjectUri = x.ProjectUri,
                            ProjectLogoUri = x.ProjectLogoUri
                        }).ToArray());
            } // using
        }

    }
}
